# + 号拼接
str1 = "hello"
str2 = "world"
result = str1 + str2
print(result, type(result))
print()

# join拼接
list = ["hello", "world"]
result = ''.join(list)
print(result, type(result))
print()

# % => 字符串拼接，字符串格式化
str1 = "hello"
str2 = "world"
# %s => 表示 "% ()" 中有数据与之对应
result = "%s%s" % (str1, str2)
print(result, type(result))
print()

num = 100
num1 = 1001
print("%d" % num)
print("%d %d" % (num, num1))
print("%o %o" % (num, num1))
print("%6d" % num)
print()

# 推挤使用format 从 python2.几 开始
str1 = "hello"
str2 = "world"
# 如果有多余的参数不会出错,但也可以指定显示
result = "{}{}".format(str1, str2, 'a')
print(result, type(result))
result = "{0}{1}".format(str1, str2, 'a')
print(result, type(result))
result = "{1}{0}".format(str1, str2, 'a')
print(result, type(result))
result = "{0}{2}".format(str1, str2, 'a')
print(result, type(result))
print()

# 关键字参数
result = "Hello, My name's {name}, age is {age}".format(name="wangwenlong", age=21)
print(result, type(result))
print()

# 推荐 f     python3.6 开始
str1 = "hello"
str2 = "world"
result = f"{str1}{str2}"
print(result, type(result))
print(f"{1 / 3:10.2f}")
print()

# 练习
message = "8*y*calil***wang*wen*long"
print('*' * message.count('*') + message.replace('*', ''))
